package values.item
{
import core.Configuration;

import framework.view.components.graphics.SWF;

import mx.utils.StringUtil;

/**
 * ItemDropValue
 * @author jliang
 * 
 */
public class ItemDropValue
{
    private static const XML_PATTERN:String = "<drop over_value=\"{0}\" class_ref=\"{1}\" url=\"{2}\" />";
    
	[Data(type="field", mapping="@over_value")]
	public var overValue:Number;
    
    [Data(type="field", mapping="@url")]
    public var baseUrl:String;

	public function get url():String
	{
		return Configuration.assetsPath + baseUrl;
	}
	
	[Data(type="field", mapping="@class_ref")]
	public var classRef:String;
	
	public function get assetMode():String
	{
		var mode:String = SWF.SINGLE;
		if (classRef && classRef != "")
		{
			mode = SWF.EXTERNAL_LIBS;
		}
		return mode;
	}
	
	public function get isSWF():Boolean
	{
		return url.indexOf(".swf") > 0;
	}
    
    public function clone():ItemDropValue
    {
        var vo:ItemDropValue = new ItemDropValue();
        vo.overValue = overValue;
        vo.baseUrl = baseUrl;
        vo.classRef = classRef;
        return vo;
    }
    
    public function generateXML():XML
    {
        var xmlStr:String = StringUtil.substitute(XML_PATTERN, 
                                                                        this.overValue,
                                                                        this.classRef,
                                                                        this.baseUrl);
        return new XML(xmlStr);
    }

}
}